//package org.activoricordi.app.snippet
package edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.snippet

/**
 * Created with IntelliJ IDEA.
 * User: naru
 * Date: 3/28/13
 * Time: 4:36 PM
 * To change this template use File | Settings | File Templates.
 */

import net.liftweb.common.{Box,Full,Empty,Failure,ParamFailure}
import net.liftweb._
import  edu.ucdavis.fiehnlab.alchemy.alchemyAdmin.model._
import util._
import Helpers._
import http._



import scala.xml._

class ViewMethod {
  /**
   * get the id of Method
   */
  var id = S.param("id") openOr ""

  /**
   * search Method by id
   */
  var method = try {
    Method.findByKey(id.toLong)
  } catch {
    case e:NumberFormatException => Empty
  }

  def view(html : NodeSeq): NodeSeq = {
    /**
     * map Method attribute on html on
     */
    method map ({ i =>
      bind("method", html,
        "name" -> i.name,
        "riWindow" -> i.riWindow,
       "mass" ->i.massWindow,
      "desc" -> i.description
      )

      /**
       * error message if no Method is found regarding id
       */


    }) openOr Text("Invalid Item")

  }
}
